package com.ymttest.database.mapping;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.ymttest.database.model.LiveRoom;

public interface LiveRoomMapper {
    
    List<LiveRoom> selectLiveRoomById(Map m);
    List<LiveRoom> selectLastLiveRoom();
    List<Map> selectLiveproductByLiveid(Map m);
    List<Map>  selectLivemember(Map m);
    List<Map> selectTopLiveproductByLiveid(Map m);
    int deleteLivemember(Map m);
    List<Map> selectLiveproductToPage(Map m);
    /**
     * update liveroom set LiveStatus=#{livestatus} where liveid= #{liveid}
     * @param m
     * @return
     */
    int updateLiveRoomPushStatus(Map m);
    
    /**
     * update liveproduct 
		<set>
			<if test="istop!=null and istop!=''">
				istop= #{istop}
			</if>
			<if test="status!=null and status!=''">
				status= #{status}
			</if>
			<if test="action!=null and action!=''">
				action= #{action}
			</if>
			</set> 
			<where>LiveProductId= #{LiveProductId}</where> 
     * @param m
     * @return
     */
    int updateLiveProductStatusById(Map m);
    int selectCountLiveroom();
    List<Map> selectLiveproductByIdAndPid(Map m);
    List<LiveRoom> selectRunningLiveRoomByUserid(Map m);
    List<Map> selectLiveRoomStatById(Map m);
    int updateLiveRoomTime(Map m);
    @Select("select * from liveonlinestat where liveid=#{liveid} order by createtime desc")
    List<Map> selectLastLiveOnlineStatById(@Param("liveid")Integer liveid);
    
    @Select("select * from livesubscribe WHERE LiveId=#{liveid} AND UserId=#{userid}")
    List<Map> selectLiveSubscribeById(@Param("liveid")Integer liveid,@Param("userid")Integer userid);
    
    @Select("select * from livevisitor WHERE deviceid=#{deviceid}" )
    List<Map> selectLivevisitorById(@Param("deviceid")String deviceid);
    @Select("select count(*) as count from liveroom where livestatus=#{status}" )
    Long selectCountLiveroomByStatus(@Param("status")Integer status);
    
    /**
     * update liveroom set action=#{action} where liveid= #{liveid}
     * @param m
     * @return
     */
    @Update("update liveroom set action=#{action} where id= #{liveid}" )
    int updateLiveRoomAction(@Param("action")Integer action,@Param("liveid")Integer liveid);
    
    @Select("select * from messagetask WHERE msgtime=#{msgtime}" )
    List<Map> selectMessagetaskByMsgtime(@Param("msgtime")String msgtime);
    
    @Select("select count(*) from livedebug WHERE liveid=#{id}" )
    Integer selectLivedebugCountById(@Param("id")String id);
    
   
    @Select(" select * from livereplay where liveid=#{liveid}" )
    List<Map> selectLivereplayById(@Param("liveid")String liveid);
}